import { createRouter, createWebHistory } from 'vue-router';
import type {RouteRecordRaw} from "vue-router";

import Index from '@/views/index.vue';

const imports = import.meta.glob<true, string, RouteRecordRaw[]>("./routes/*.{ts,js}", {eager: true, import: "default"});
const routes: RouteRecordRaw[] = [];
for(const key in imports) {
  routes.push(...imports[key]);
}

export default createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Index,
      children: routes
    },
    {
      path: '/login',
      name: '登录',
      component: () => import("@/views/login.vue")
    },
  ]
});
